package com.synnex.mobile.servier.core.survey.dao.impl;

import com.synnex.mobile.generic.dao.impl.GenericHibernateDaoImpl;
import com.synnex.mobile.servier.core.survey.dao.QuestionnaireDao;
import com.synnex.mobile.servier.core.survey.dto.Questionnaire;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-8-10
 * Time: 上午9:54
 * To change this template use File | Settings | File Templates.
 */
public class QuestionnaireDaoImpl extends GenericHibernateDaoImpl<Questionnaire,Integer> implements QuestionnaireDao{
    public List<Questionnaire> getQuestionnaires() {
        Criteria c =  this.getSession().createCriteria(Questionnaire.class);
        c.addOrder(Order.asc("seq"));
        return c.list();
    }

    public void save(Questionnaire dto) {
        super.save(dto);
    }

    public Questionnaire getQuestionById(Integer id) {
        return super.get(id);
    }

    public void editQuestionnaire(Questionnaire questionnaire) {
        super.update(questionnaire);
    }

    public void deleteQuestionnaire(Integer id) {
        super.delete(super.get(id));
    }
}
